package br.com.atenas.sigop.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import br.com.atenas.sigop.dto.TpMaterialDTO;

public class TpMaterialDAO {
	private String tabela = " SIGOP.TB007_TPMATERIAL ";

	
	public List<TpMaterialDTO> listar(Connection conn) throws Exception{
		List<TpMaterialDTO> tpMateriais = new ArrayList<TpMaterialDTO>();
		String sql = " SELECT * FROM" + tabela;
		PreparedStatement ps = conn.prepareStatement(sql);
//		ps.setString(1, tpMaterial.getNoTpMaterial()+"%");
		
		ResultSet rs = ps.executeQuery();
		while(rs.next()){
			TpMaterialDTO tpMaterialResultado = new TpMaterialDTO();
			tpMaterialResultado.setNuTpMaterial(rs.getBigDecimal("NU_TPMATERIAL"));
			tpMaterialResultado.setNoTpMaterial(rs.getString("NO_TPMATERIAL"));
			tpMateriais.add(tpMaterialResultado);
		}
		return tpMateriais;
	}
}
